<?php

/**
 * This is the model class for table "tbl_resp_modulos".
 *
 * The followings are the available columns in table 'tbl_resp_modulos':
 * @property integer $rmo_id
 * @property string $rmo_codigo
 * @property string $rmo_resp
 * @property string $rmo_modulo
 * @property integer $rmo_terminado
 * @property integer $rmo_estado
 */
class tbl_resp_modulos extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return tbl_resp_modulos the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_resp_modulos';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rmo_codigo, rmo_resp, rmo_modulo, rmo_terminado, rmo_estado', 'required'),
			array('rmo_terminado, rmo_estado', 'numerical', 'integerOnly'=>true),
			array('rmo_codigo', 'length', 'max'=>10),
			array('rmo_resp', 'length', 'max'=>7),
			array('rmo_modulo', 'length', 'max'=>4),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('rmo_id, rmo_codigo, rmo_resp, rmo_modulo, rmo_terminado, rmo_estado', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
            'rpta'=>array(self::BELONGS_TO, 'tbl_resp', array('rmo_resp'=>'rma_codigo')),
            'modu'=>array(self::BELONGS_TO, 'tbl_modulos', array('rmo_modulo'=>'mod_codigo'))
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'rmo_id' => 'Rmo',
			'rmo_codigo' => 'Rmo Codigo',
			'rmo_resp' => 'Rmo Resp',
			'rmo_modulo' => 'Rmo Modulo',
			'rmo_terminado' => 'Rmo Terminado',
			'rmo_estado' => 'Rmo Estado',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('rmo_id',$this->rmo_id);

		$criteria->compare('rmo_codigo',$this->rmo_codigo,true);

		$criteria->compare('rmo_resp',$this->rmo_resp,true);

		$criteria->compare('rmo_modulo',$this->rmo_modulo,true);

		$criteria->compare('rmo_terminado',$this->rmo_terminado);

		$criteria->compare('rmo_estado',$this->rmo_estado);

		return new CActiveDataProvider('tbl_resp_modulos', array(
			'criteria'=>$criteria,
		));
	}
}